Repository navigation
fix(schedule): bound AI task runs and wait for SOP outcomes - #1080
Conversation
定时任务超时与 SOP 终态实测复测通过。 在提交
以上两条当前提交的运行均未调用 本轮执行记录(两条均为定时触发) 已保存的 1 分钟超时和 Flash 模型配置 草稿回退、单次启动,以及超时取消等待的网关记录 定时会话超时后,独立 SOP 的最终结果 |
Robert0622
left a comment
There was a problem hiding this comment.
0c3e528b 的等待和执行超时通过独立复测。用 CodeBuddy iOA 的 DeepSeek V4.1 Flash,通过定时助手读取隔离测试库中预置的 SOP 状态,并在 Go HTTP 路由统计实际请求。
- SOP 为
waiting时,定时助手调用runs_wait1 次,18.439 秒后报回匹配的运行 ID 和waiting。 - SOP 保持
running、定时任务时限为 1 分钟时,助手发起 2 次等待,第 2 次由截止时间取消。60.061 秒后该轮生成记录为failed / EXECUTION_TIMEOUT,SOP 状态仍为running。
定时任务配置、旧任务默认时限、超过 5 分钟的网关会话、取消等待及终态草稿回归也已通过。当前合并阻塞在 internal/httpapi/assistant_schedule.go 和 internal/httpapi/assistant_tasks.go。与 main@6a331fb5 解决冲突时,需要同时保留本 PR 的 Timeout 和主线的 ReportUsage 回调及其执行上下文,否则定时任务会丢失超时或用量统计。
Robert0622
left a comment
There was a problem hiding this comment.
复审通过 · 4a94f4d7
用真实 iOA CodeBuddy(deepseek-v4.1-flash)通过定时助手访问隔离测试库。SOP 为 waiting 时,助手发出 1 次 runs_wait,38.638s 后返回匹配的运行 ID 和状态。SOP 持续 running、任务时限为 1 分钟时,助手发出 2 次等待,1 次由截止时间取消,1m0.201s 后生成记录为 failed / EXECUTION_TIMEOUT。两次均记录实际模型和用量,SOP 自身状态与测试前一致。超时配置、取消和工具会话回归也已通过。
已核对本提交的差异和 GitHub 检查,当前没有发现阻塞合并的问题。
crispinhu27
left a comment
There was a problem hiding this comment.
初审结论:REQUEST_CHANGES(head 4a94f4d7,base main@5fadefca)
审查范围:完整 diff,包括执行超时(executeAssistantTask / runScheduleJobPromptResult / generation 超时分类)、runs_wait 端点与工具网关免锁、定时会话 SOP 派发草稿拦截、schedule 配置校验、Web 表单、OpenAPI/MCP 契约,以及相关调用方和权限链路。
已执行的验证(隔离环境,未接触任何凭据):
go build ./...和go vet(touched 包)通过;internal/domain、internal/repo、web测试通过。internal/httpapi全量测试:只有TestMainBotBrowserStartsAndDrivesRunBrowser和TestBrowserStreamPushesFramesAndRunsCommands失败。在 merge-base5fadefca上同样失败,是本容器 Chromium 的环境问题,与本 PR 无关;GitHub 上的 browser 检查是通过的。- webtest
sync-schedule.test.mjs17/17 通过。 - 用本 head 构建的服务连隔离的 MariaDB 实际运行,复现了下面行内评论里的问题,并做了带 projectId 的对照。
阻塞问题:1 个 [P2],见行内评论(runs_wait 对不带 projectId 启动的 SOP 返回 403)。
未验证:没有用真实模型做端到端的定时提示词回归(需要模型凭据);超时取消路径只依据单测和 PR 描述中的实测结果,本次没有另行复测。
# Conflicts: # internal/httpapi/agent_tool_mcp.go
crispinhu27
left a comment
There was a problem hiding this comment.
复审结论:APPROVE(head 8b77d152,base main@edc27c0,PR 内已合入 main@fe053a1)
历史问题
- [P2]
runs_wait对不带projectId启动的 SOP 返回 403:FIXED。在隔离 MariaDB 上用真实服务复测,原触发条件下上一版 head4a94f4d7返回 403,本 head 返回 200,详见原线程。
本次审查范围
612e092d:waitRun的项目解析顺序是 executionContext → issue 项目 → 冻结的 workflow snapshot(RunWorkflowProjectID),以及新增的回归测试。- 合并提交
8b77d152:--remerge-diff显示只有internal/httpapi/agent_tool_mcp.go一处冲突。解决后同时保留了本 PR 的validateScheduledRunDrafts和主线 #991 的vetSOPDesignerReply。合并前后 PR 的净 diff 一致(25 个文件,+529/−35)。
已执行的验证(隔离环境,不接触任何凭据)
go build ./...、go vet(httpapi/repo/domain)通过。internal/domain、internal/repo、internal/schedule、web测试通过。internal/httpapi全量测试只有TestMainBotBrowserStartsAndDrivesRunBrowser和TestBrowserStreamPushesFramesAndRunsCommands失败。这两个用例在 merge-base5fadefca上同样失败,原因是本容器的 Chromium 环境,GitHub 的 browser 检查是通过的。TestScheduledCodexCacheWriteUsage偶发失败,merge-base 上 10 次失败 6 次,本 head 10 次失败 3 次,属于已有的不稳定用例。- 执行超时运行验证:用一个接受 turn 后不再结束的假 codex CLI(
AGENTFLOW_CODEX_BIN,合成凭据)创建timeoutMinutes=1的定时任务并立即运行。09:16:52 开始,09:17:52 终止。任务状态为failed / 定时任务执行超时,generation 记录为failed,failure.code=EXECUTION_TIMEOUT,假 CLI 进程已被回收。 - GitHub 检查:本 head 的 platform-required、e2e-required 等 16 项检查全部通过。
未覆盖:没有用真实模型跑端到端的定时提示词回归,因为需要模型凭据。超时和 runs_wait 的服务端行为已经按上面的方式实际运行验证。




Problem
The v0.4.0 scheduled assistant had no per-execution deadline. SOP dispatch returned immediately, so unattended prompts that needed an outcome could keep querying run details and logs indefinitely.
Changes
runs_waittool. It waits on the exact run ID using a lightweight status query, returns when the run completes or needs human action, and yields after at most 25 seconds per call. Scheduled prompts use it when they need to wait for an SOP outcome.Validation
TestScheduledAssistantHasNoDeadlineatv0.4.0to confirm the missing execution deadline.go vet, public content check, and Gitleaks scan also passed.Live CodeBuddy regression
Real DeepSeek V4.1 Flash was used for the timer prompt and the SOP Agent node on isolated MySQL instances. The Agent wrote a marker artifact, which the following script verified.
runs_getcalls before reporting SOP success at 121.7 seconds.7382983f), slow SOP, one-minute timeoutruns_waitcalls, including the wait that was cancelled at the deadline. The dispatched SOP later succeeded.7382983f), short SOPruns_waitcall and reported the correct success state in 36.8 seconds.The v0.4.0 run eventually reached the correct outcome in this fixture. The comparison reproduced the omitted deadline and repeated reads.
Follow-up live regression
A fresh timer run exposed another path on
7382983f. The model submittedruns_startas a final reply draft. The schedule recorded success after 15.0 seconds, applied the draft after the CLI exited, and never checked the SOP outcome.Commit
0c3e528bkeeps scheduled SOP dispatch in the active turn. The gateway directs the model to call the dispatch tool, and text recovery rejects a leftover dispatch draft before it can run. The added regression tests cover start, issue dispatch, retry, and the recovered-draft path.We repeated both timer cases with CodeBuddy on DeepSeek V4.1 Flash and isolated MySQL. Each dispatched one SOP. A real Agent wrote a unique marker in each run, a script checked it, and both the marker and completion artifact were read back from storage.
runs_waitreturnedsucceeded. The timer reported the correct run ID and finished in 40.398 seconds.runs_waitcalls. The deadline cancelled the second wait (HTTP 408) and the timer recordedEXECUTION_TIMEOUTat 60.101 seconds. The independent SOP later succeeded.Neither timer called
runs_get. A later read found the same persisted generation sequence and update timestamp for both completed timer executions.